package com.yuxiu.edu.web.controller.base;

import java.lang.reflect.ParameterizedType;

public abstract class BaseController<T> {
    public String MANAGE_PAGE;
    public String INFO_PAGE ;
    public String EDIT_PAGE;

    public final String MANAGE = "mange";
    public final String INFO = "info";
    public final String EDIT = "edit";

    public BaseController() {
        //当前类的名称及其泛型
        ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass();

        //抽取泛型
        Class<?> modelClass = (Class<?>) type.getActualTypeArguments()[0];

        //获取模块名字
        String modelName = modelClass.getSimpleName().toLowerCase();

        //给静态页面赋值
        MANAGE_PAGE = modelName + "/" + MANAGE;
        MANAGE_PAGE = modelName + "/" + INFO;
        MANAGE_PAGE = modelName + "/" + EDIT;

    }
}
